from pydantic import BaseModel
from starlette import status
from fastapi.responses import Response, JSONResponse
from typing import Optional, Sequence

from schemas import (
    Activity,
    RespList,
    RespInfo
)


def resp_200(total: int = None, data: Optional[Sequence[BaseModel]] = None):

    return RespList(total=total, list=data).dict(exclude_none=True)


def resp_detail_200(data: BaseModel = None):

    return RespInfo(info=data).dict(exclude_none=True)


def resp_400():
    return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST,
                        content={"ret": 400, "ret_msg": ""}
                        )
